package com.aat.dxfy.mouse;

import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;

public class RobotExp {

	public static void leftClick(Robot robot, int x, int y) {
		robot.delay(1000);
		robot.mouseMove(x, y);
		robot.delay(1000);
		robot.mousePress(InputEvent.BUTTON1_MASK);
		robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
		robot.delay(1000);
	}

	public static void pressKey(Robot robot, int keyvalue) {
		robot.keyPress(keyvalue);
		robot.keyRelease(keyvalue);
	}

	public static void pressKeyWithShift(Robot robot, int keyvalue) {
		robot.keyPress(KeyEvent.VK_SHIFT);
		robot.keyPress(keyvalue);
		robot.keyRelease(keyvalue);
		robot.keyRelease(KeyEvent.VK_SHIFT);
	}

	public static void closeApplication(Robot robot) {
		// pressKey(robot, KeyEvent.VK_ALT);
		// pressKey(robot, KeyEvent.VK_F4);
		robot.keyPress(KeyEvent.VK_ALT);
		robot.keyPress(KeyEvent.VK_F4);
		robot.keyRelease(KeyEvent.VK_ALT);
		robot.keyRelease(KeyEvent.VK_F4);
		// for linux.
		// robot.keyPress(KeyEvent.VK_ALT);
		// robot.keyPress(KeyEvent.VK_W);
		// robot.keyRelease(KeyEvent.VK_ALT);
		// robot.keyRelease(KeyEvent.VK_W);
		robot.keyPress(KeyEvent.VK_N);
		robot.keyRelease(KeyEvent.VK_N);
	}

}